package controllers;

import connectivity.Dbmanager;
import connectivity.QueryManager;
import java.io.*;
import java.util.LinkedList;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.swing.JOptionPane;
import models.User;

public class DeleteUserController extends HttpServlet {

    private Dbmanager dbManager;
    private QueryManager queryManager;

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws IOException, ServletException {
        User user = new User();
        
        dbManager = new Dbmanager();
        dbManager.openConnection();
        queryManager = new QueryManager(dbManager);
        
        if (request.getParameter("id") != null) {
            //Als er een id is meegegeven, worden de gegevens van de gebruiker opgehaald.
            int id = (int) Long.parseLong(request.getParameter("id"));
   
            queryManager.deleteuserbyid(id);
        }

        String address = "/manage_users";
        dbManager.closeConnection();
        RequestDispatcher dispatcher = request.getRequestDispatcher(address);
        dispatcher.forward(request, response); //Stuurt door naar de Gebruikers index

    }
}
